<?php

namespace app\common\validate;

use think\Validate;

class School extends Validate
{
    /**
     * 验证规则
     */
    protected $rule = [
        'name'            => 'require|unique:School,name',
        'province_id'     => 'require',
        'city_id'         => 'require',
        'district_id'     => 'require',
    ];

    /**
     * 提示消息
     */
    protected $message = [
    ];

    /**
     * 字段描述
     */
    protected $field = [
    ];

    /**
     * 验证场景
     */
    protected $scene = [
        'add'  => ['name', 'province_id', 'city_id', 'district_id'],
        'edit' => ['name' => 'require|unique:School,name^id', 'province_id', 'city_id', 'district_id'],
    ];

    public function __construct(array $rules = [], $message = [], $field = [])
    {
        $this->field = [
            'name' => __('名称'),
            'province_id' => __('省'),
            'city_id' => __('市'),
            'district_id' => __('区'),
        ];
        parent::__construct($rules, $message, $field);
    }

}
